package com.aiyan.edu.govern.gateway.admin.controller;

import com.aiyan.edu.api.gateway.RoutesControllerApi;
import com.aiyan.edu.framework.domain.gateway.GwRoute;
import com.aiyan.edu.framework.domain.gateway.request.QueryRouteRequest;
import com.aiyan.edu.framework.domain.gateway.response.GatewayResponseResult;
import com.aiyan.edu.framework.model.response.QueryResponseResult;
import com.aiyan.edu.framework.web.BaseController;
import com.aiyan.edu.govern.gateway.admin.service.RoutesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: zqzhou
 * @create: 2019/12/01 17:19
 **/
@RestController
@RequestMapping("/gw/routes")
public class RoutesController extends BaseController implements RoutesControllerApi {

    @Autowired
    RoutesService routesService;

    @Override
    @PostMapping("")
    public GatewayResponseResult<GwRoute> save(@RequestBody GwRoute gwRoute) {
        return this.routesService.save(gwRoute);
    }

    @Override
    @GetMapping("/list/{page}/{size}")
    public QueryResponseResult<GwRoute> list(@PathVariable("page") int page, @PathVariable("size") int size, QueryRouteRequest queryRouteRequest) {
        return this.routesService.list(page, size, queryRouteRequest);
    }

    @Override
    @PostMapping("/post/{routeId}")
    public GatewayResponseResult<GwRoute> post(@PathVariable("routeId") String routeId) {
        return this.routesService.post(routeId);
    }
}
